# 这是一个示例 Python 脚本。
import json

# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。

# 采集百度翻译的结果
import requests

# 按装订区域中的绿色按钮以运行脚本。
if __name__ == '__main__':
    for i in range(1, 10):
        url = 'http://192.168.100.113/api/setmeal'
        params = {
            type: 1
        }
        data = {
            "name": str(i),
            "categoryId": 13,
            "price": "999",
            "code": "",
            "image": "https://sky-itcast.oss-cn-beijing.aliyuncs.com/862625fc-4c41-4bec-b236-19fbd29fc440.png",
            "description": "999",
            "dishList": [],
            "status": 0,
            "idType": 13,
            "setmealDishes": [
                {
                    "copies": 1,
                    "dishId": 64,
                    "name": "馋嘴牛蛙",
                    "price": 88
                }
            ]
        }
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
        'Token': 'eyJhbGciOiJIUzI1NiJ9.eyJlbXBJZCI6MSwiZXhwIjoxNzQ2MTk1NDM1fQ.Z8_9_uP5HLQOGVWd_cY5KEuAoJKjbAZCYsa5HaDaN2k',
        'Cokkie': 'username=admin; token=eyJhbGciOiJIUzI1NiJ9.eyJlbXBJZCI6MSwiZXhwIjoxNzQ2MTk1NDM1fQ.Z8_9_uP5HLQOGVWd_cY5KEuAoJKjbAZCYsa5HaDaN2k; user_info={%22id%22:1%2C%22userName%22:%22admin%22%2C%22name%22:%22%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22token%22:%22eyJhbGciOiJIUzI1NiJ9.eyJlbXBJZCI6MSwiZXhwIjoxNzQ2MTk1NDM1fQ.Z8_9_uP5HLQOGVWd_cY5KEuAoJKjbAZCYsa5HaDaN2k%22}'
    }
    # 1.发起请求
    r = requests.post(url, json=data, headers=headers)
    # 2.打印输出
print(r.json())
# 3.持久化存储
fp = open('./csdn.json', 'w', encoding='utf-8')
json.dump(r.json(), fp, ensure_ascii=False)
